/*************************************
 * Joe Helgeson
 * CS362 Assignment 3
 * Unit tests for various 
 * non-card-specific functions
 *
 * unittest2.c test for numHandCards()
 ************************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>

//enabling debugging messages to appear
//#ifdef DEBUG
//#undef DEBUG
//#endif
//#define DEBUG 1

void testIt(struct gameState* tState);

///////////////////////////////////////
int main(int argc, char const** argv) {
	struct gameState* tState = malloc(sizeof(struct gameState));
	srand(time(NULL));	//init random seed
	testIt(tState);
	free(tState);
	return 0;
}

///////////////////////////////////////
void testIt(struct gameState* tState) {

	int t; 	//test number
	for(t=0; t<50; t++) {
		//setup
		tState->whoseTurn = rand() % 4;		//pick a random player
		int nCrds = rand() % 15; 			//randomly set # cards in hand
		tState->handCount[whoseTurn(tState)] = nCrds;  //set hand count

		//run numHandCards()
		int res = numHandCards(tState);
	
		//compare result to actual hand count
		if(res == nCrds) {
			printf("Test Passed for %d card hand (expected %d).\n", res, nCrds);
		}
		else {
			printf("Test Failed for %d card hand (expected %d).\n", res, nCrds);
			return;
		}
	}
		printf("Unit test for numHandCards() passed.\n");
		return;

}

